package cl.lexer.validator;

import java.util.ArrayList;
import java.util.List;

import cl.lexer.Token;
import cl.lexer.TokenType;

public class TypeValidator implements TokenValidator {
    
    private static List<String> keywords;
    
    static {
        keywords = new ArrayList<String>();
        
        keywords.add("int");
        keywords.add("char");
        keywords.add("float");
        keywords.add("double");
        keywords.add("long");
        
        keywords.add("void");
    }
    
    @Override
    public TokenType getType() {
        return TokenType.TYPE;
    }

    @Override
    public boolean isValid(String value) {
        for(String s : keywords) {
            if(s.equals(value)) {
                return true;
            }
        }
        
        return false;
    }

    @Override
    public boolean possiblyValid(String value) {
        for(String s : keywords) {
            if(s.indexOf(value) == 0) {
                return true;
            }
        }
        
        return false;
    }

    @Override
    public Token generateToken(String value) {
        return new Token(TokenType.TYPE, value);
    }

}
